#include <stdio.h>
#include <windows.h>

#ifndef __stdcall
#	define __stdcall __attribute__((__stdcall__))
#endif//__stdcall

bool install_hook(void* ppSystemFunction, void* pHookFunction);
bool uninstall_hook(void* ppHookedFunction);

typedef HHOOK (WINAPI* API_SetWindowsHookExA)(int idHook, HOOKPROC lpfn, HINSTANCE hmod, DWORD dwThreadId);

API_SetWindowsHookExA set_windows_hook_ex_a = NULL;

BOOL WINAPI enum_windows_handler(WNDENUMPROC lpEnumFunc, LPARAM lParam)
{
	return FALSE;
}
HHOOK WINAPI set_windows_hook_ex_a_handler(int idHook, HOOKPROC lpfn, HINSTANCE hmod, DWORD dwThreadId)
{
	if (WH_KEYBOARD_LL == idHook)
		dwThreadId = GetCurrentThreadId();

	set_windows_hook_ex_a(idHook, lpfn, hmod, dwThreadId);
}
int main(int argc, const char* argv[])
{
	HANDLE dll_handle = LoadLibraryA("user32.dll");
	if (NULL != dll_handle)
	{
		set_windows_hook_ex_a = (API_SetWindowsHookExA)GetProcAddress(dll_handle, "SetWindowsHookExA");
		if (NULL != set_windows_hook_ex_a)
		{
			install_hook(&set_windows_hook_ex_a, &set_windows_hook_ex_a_handler);
		}
	}
	return 0;
}